/**
 Emma_project
 Copyright (C) 2015  Rodrigo Garcia

 This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
/*
  This module checks the configured time to log data.
 */

#ifndef TIMECHECKER_H

#define TIMECHECKER_H

#include "rtcDS3231.h"
#include "EEPROMd.h"
#include "DataLogger.h"

// eeprom address for time interval
#define TIME_INTERVAL_SEC 0x10
#define TIME_INTERVAL_MIN 0x11
#define TIME_INTERVAL_HOUR 0x12

unsigned char is_time_to_log;

long last_time_logged_sum, current_time_sum, interval_time_sum;

struct RTC_time rtc_time;

void CheckForConfiguredTime(struct LogFile *data_log);

void UpdateConfiguredTimeFromEEPROM(void);
void UpdateLastLoggedTime(void);
void SetTimeInterval(unsigned char hour, unsigned char min, unsigned char sec);

void UpdateFileNameToCurrentDate(struct LogFile *data_log);
#endif
